#pragma once 

namespace vanjee
{
    namespace lidar
    {
        class Params_ScanData0728
        {

        public:
        #pragma pack(push)
        #pragma pack(1)
                // 数据块 角度信息
            struct ViewField
            {
                // 计时值
                unsigned short timing_value;
                // 反射率
                unsigned char reflectivity;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataBlock
            {
                // 数据块的起始标志
                unsigned char data_block_start_flag = 0;
                // 转镜
                unsigned char rotating_mirror_id = 0;
                // 水平角度
                short h_angle = 0;
                // 水平角度分辨率 0.1 / 0.2
                unsigned char h_angle_resolution = 0;
                // 阈值选择 1 低阈值 2高阈值
                unsigned char high_or_low_thres = 0;
                // 回波类型 1 最强一重 2最后一重
                unsigned char echo_type = 0;
                // 垂直方向补偿角 有符号
                char v_compensate_angle = 0;
                // 水平方向补偿角 有符号
                int h_compensate_angle = 0;

                ViewField view_field[48] = {{0}};
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            struct ScanData // 扫描协议
            {
                unsigned char head[2] = {0,0};
                unsigned short frame_len = 0;     
                // 设备编号
                unsigned short device_id = 0;
                // 帧类别
                unsigned short frame_type = 0;
                // 当前帧创建时间
                unsigned char create_time[12] = {0};
                // 帧序号
                unsigned short frame_id = 0;
                // 网络协议版本号
                unsigned char network_version[4];
                // 水平偏移角
                unsigned short horizontal_offset_angle;

                DataBlock data_block[8];
                unsigned char check = 0;
            };
        #pragma pack(pop)

        public:
            ScanData data_;
            const int view_field_size_ = 48;
            const int data_block_size_ = 8;

            // 获取当前帧的回波模式 1：双回波 2：单回波
            unsigned char GetEchoModel()
            {
                if(data_.data_block[0].echo_type != data_.data_block[1].echo_type)
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
            int GetHCompensateAngle(int date_block_index);
        };

        class Params_ScanData0728Reflectivity
        {

        public:
        #pragma pack(push)
        #pragma pack(1)
                // 数据块 角度信息
            struct ViewField
            {
                // 计时值
                unsigned short timing_value;
                // 反射率
                unsigned char reflectivity;
                // 低阈值脉宽
                unsigned short low_thres_pulsewitdh;
                // 高阈值脉宽
                unsigned short high_thres_pulsewidth;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataBlock
            {
                // 数据块的起始标志
                unsigned char data_block_start_flag = 0;
                // 转镜
                unsigned char rotating_mirror_id = 0;
                // 水平角度
                short h_angle = 0;
                // 水平角度分辨率 0.1 / 0.2
                unsigned char h_angle_resolution = 0;
                // 阈值选择 1 低阈值 2高阈值
                unsigned char high_or_low_thres = 0;
                // 回波类型 1 最强一重 2最后一重
                unsigned char echo_type = 0;
                // 垂直方向补偿角 有符号
                char v_compensate_angle = 0;
                // 水平方向补偿角 有符号
                int h_compensate_angle = 0;

                ViewField view_field[48] = {{0}};

                // 48个通道强弱发光
                unsigned char strong_weak[6] = {0};
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            struct ScanData // 扫描协议
            {
                unsigned char head[2] = {0,0};
                unsigned short frame_len = 0;     
                // 设备编号
                unsigned short device_id = 0;
                // 帧类别
                unsigned short frame_type = 0;
                // 当前帧创建时间
                unsigned char create_time[12] = {0};
                // 帧序号
                unsigned short frame_id = 0;
                // 网络协议版本号
                unsigned char network_version[4];
                // 水平偏移角
                unsigned short horizontal_offset_angle;

                DataBlock data_block[4];
                unsigned char check = 0;
            };
        #pragma pack(pop)

        public:
            ScanData data_;
            const int view_field_size_ = 48;
            const int data_block_size_ = 4;
            // 获取当前帧的回波模式 1：双回波 2：单回波
            unsigned char GetEchoModel()
            {
                if(data_.data_block[0].echo_type != data_.data_block[1].echo_type)
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
        };

        class Params_ScanData1122
        {

        public:
        #pragma pack(push)
        #pragma pack(1)
                // 数据块 角度信息
            struct ViewField
            {
                // 计时值
                unsigned short timing_value;
                // 反射率
                unsigned char reflectivity;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataBlock
            {
                // 数据块的起始标志
                unsigned char data_block_start_flag = 0;
                // 转镜
                unsigned char rotating_mirror_id = 0;
                // 水平角度
                short h_angle = 0;
                // 水平角度分辨率 0.1 / 0.2
                unsigned char h_angle_resolution = 0;
                // 阈值选择 1 低阈值 2高阈值
                unsigned char high_or_low_thres = 0;
                // 回波类型 1 最强一重 2最后一重
                unsigned char echo_type = 0;
                // 垂直方向补偿角 有符号
                char v_compensate_angle = 0;
                // 水平方向补偿角 有符号
                int h_compensate_angle = 0;

                ViewField view_field[48] = {{0}};
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataIMU
            {
                // x方向补偿位移
                unsigned short distance_offset_x = 0;
                // y方向补偿位移
                unsigned short distance_offset_y = 0;
                // z方向补偿位移
                unsigned short distance_offset_z = 0;
                // 四元数w值
                float quaternion_w = 0;
                // 四元数x值
                float quaternion_x = 0;
                // 四元数y值
                float quaternion_y = 0;
                // 四元数z值
                float quaternion_z = 0;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            struct ScanData // 扫描协议
            {
                unsigned char head[2] = {0,0};
                unsigned short frame_len = 0;     
                // 设备编号
                unsigned short device_id = 0;
                // 帧类别
                unsigned short frame_type = 0;
                // 当前帧创建时间
                unsigned char create_time[12] = {0};
                // 帧序号
                unsigned short frame_id = 0;
                // 网络协议版本号
                unsigned char network_version[4];
                // 水平偏移角
                unsigned short horizontal_offset_angle;

                DataBlock data_block[8];
                DataIMU data_imu;
                unsigned char check = 0;
            };
        #pragma pack(pop)

        public:
            ScanData data_;
            const int view_field_size_ = 48;
            const int data_block_size_ = 8;

            // 获取当前帧的回波模式 1：双回波 2：单回波
            unsigned char GetEchoModel()
            {
                if(data_.data_block[0].echo_type != data_.data_block[1].echo_type)
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
            int GetHCompensateAngle(int date_block_index);
        };

        class Params_ScanData1122Reflectivity
        {

        public:
        #pragma pack(push)
        #pragma pack(1)
                // 数据块 角度信息
            struct ViewField
            {
                // 计时值
                unsigned short timing_value;
                // 反射率
                unsigned char reflectivity;
                // 低阈值脉宽
                unsigned short low_thres_pulsewitdh;
                // 高阈值脉宽
                unsigned short high_thres_pulsewidth;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataBlock
            {
                // 数据块的起始标志
                unsigned char data_block_start_flag = 0;
                // 转镜
                unsigned char rotating_mirror_id = 0;
                // 水平角度
                short h_angle = 0;
                // 水平角度分辨率 0.1 / 0.2
                unsigned char h_angle_resolution = 0;
                // 阈值选择 1 低阈值 2高阈值
                unsigned char high_or_low_thres = 0;
                // 回波类型 1 最强一重 2最后一重
                unsigned char echo_type = 0;
                // 垂直方向补偿角 有符号
                char v_compensate_angle = 0;
                // 水平方向补偿角 有符号
                int h_compensate_angle = 0;

                ViewField view_field[48] = {{0}};

                // 48个通道强弱发光
                unsigned char strong_weak[6] = {0};
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            // 数据块
            struct DataIMU
            {
                // x方向补偿位移
                unsigned short distance_offset_x = 0;
                // y方向补偿位移
                unsigned short distance_offset_y = 0;
                // z方向补偿位移
                unsigned short distance_offset_z = 0;
                // 四元数w值
                float quaternion_w = 0;
                // 四元数x值
                float quaternion_x = 0;
                // 四元数y值
                float quaternion_y = 0;
                // 四元数z值
                float quaternion_z = 0;
            };
        #pragma pack(pop)

        #pragma pack(push)
        #pragma pack(1)
            struct ScanData // 扫描协议
            {
                unsigned char head[2] = {0,0};
                unsigned short frame_len = 0;     
                // 设备编号
                unsigned short device_id = 0;
                // 帧类别
                unsigned short frame_type = 0;
                // 当前帧创建时间
                unsigned char create_time[12] = {0};
                // 帧序号
                unsigned short frame_id = 0;
                // 网络协议版本号
                unsigned char network_version[4];
                // 水平偏移角
                unsigned short horizontal_offset_angle;

                DataBlock data_block[4];
                DataIMU data_imu;
                unsigned char check = 0;
            };
        #pragma pack(pop)

        public:
            ScanData data_;
            const int view_field_size_ = 48;
            const int data_block_size_ = 4;
            // 获取当前帧的回波模式 1：双回波 2：单回波
            unsigned char GetEchoModel()
            {
                if(data_.data_block[0].echo_type != data_.data_block[1].echo_type)
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
        };
    }
}
